﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="jquery.js"></script>
</head>
<body>
    <button id="submit">submit</button>
    <p id="result" style="color:orangered;font-weight:bold;font-size:24px;"></p>
</body>
</html>
<script src="signalr.js"></script>
<!--<script src="./index.js"></script>-->
<script>
    let connection = null;
    setupConnection = () => {
        connection = new signalR.HubConnectionBuilder()
            .withUrl("/signalr", {
                skipNegotiation: true,
                transport: signalR.HttpTransportType.WebSockets
            })
            .build();
        connection.start().catch(err => console.error(err.toString()));
    }
    setupConnection();
    document.getElementById("submit").addEventListener("click", e => {
        connection.invoke("AdminSendMessage").catch(
            err => console.log(err)
        )
    });

    connection.on("getMessage", (update) => {
        const resultdiv = document.getElementById("result");
        resultdiv.innerHTML = update;
    });
</script>